# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=vane
pkgver=1899.48f9ab5
pkgrel=12
groups=('blackarch' 'blackarch-webapp' 'blackarch-scanner' 'blackarch-fuzzer')
pkgdesc='A vulnerability scanner which checks the security of WordPress installations using a black box approach.'
arch=('any')
url='https://github.com/delvelabs/vane'
license=('GPL3')
depends=('ruby' 'libxslt' 'ruby-bundler')
makedepends=('git')
options=(!strip)
source=("git+https://github.com/delvelabs/$pkgname.git"
        'gemfile.patch')
sha512sums=('SKIP'
            '291b53c7e74b87c9ce78e257ce58e3b04147c601ea03196cd434052bc6ceeed3d474f005e12b78ee061269622bd8f5e66dd387f46a1064703bb54d16102750bd')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < gemfile.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a * "$pkgdir/usr/share/$pkgname"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec $pkgname.rb "\$@"
EOF

  sed -i "s/ROOT_DIR, 'log.txt'/ENV['HOME'], 'vane.log'/" "$pkgdir/usr/share/$pkgname/lib/common/common_helper.rb"
  sed -i "s/ROOT_DIR, 'cache'/ENV['HOME'], '.vane-cache'/" "$pkgdir/usr/share/$pkgname/lib/common/common_helper.rb"

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

